<?php

class Admin_Form_AreaAcademica extends Zend_Form {

    public function init() {
        $default_messages = Zend_Registry::get('default_messages');
        // Set the method for the display form to POST
        $this->setMethod('post');
        $this->setAttrib("id", "areaaacademica-form");
        $this->setAction('/admin/areaacademica/save');
        $this->setAttrib('class', 'form-horizontal mini-layout-body');
        $this->addElementPrefixPath('Admin', 'admin/');
        $this->addElement('hidden', 'codigo_area_academica');

        $this->addElement('text', 'nombre', array(
            'label' => 'Nombre:',
            'required' => true,
            'filters' => array('StringTrim'),
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(2, 50))
            )
        ));

        $this->addElement('text', 'descripcion', array(
            'label' => 'Descripcion:',
            'required' => false,
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 255))
            )
        ));
        
        // este usuario tendra los datos de contacto como email, nombre completo,
        // no ser el username de conexion al cloudstack
        $usuario = new Application_Model_Mapper_Usuario();
        $usuario_db = $usuario->fetchAll();
        $username = new Zend_Form_Element_Select('username');
        $username->addMultiOption(-1, $default_messages->input_select_select); // debe de ser un mensaje
        foreach ($usuario_db as $value) {
            $c = $value->toArray();
            $username->addMultiOption($c['username'], $c['username']);
        }
        $username->setLabel('Usuario');
        $this->addElement($username);

        
        
        // username para cloudstack
        // FALTA UNA VERIFICACION AJAX DE DISPONIBILIDAD DEL USERNAME
        $this->addElement('text', 'username_account', array(
            'label' => 'Usuario area academica:',
            'required' => false,
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(1, 255))
            )
        ));

        // username para cloudstack
        $this->addElement('password', 'password', array(
            'label' => 'Password area academica:',
            'required' => false,
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(1, 255))
            )
        ));
        
        $this->addElement('submit', 'submit', array(
            'ignore' => true,
            'label' => 'Guardar',
            'class' => 'btn btn-large btn-primary'
        ));
        
        $this->addElement('button', 'cancel', array(
            'ignore' => true,
            'label' => 'Cancelar',
            'onclick' => 'back()',
            'class' => 'btn btn-large btn-primary'
        ));
    }

}

?>
